﻿<!DOCTYPE html>
<!--总体评估考核评分-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>
    <link href="../static/js/vue-treeselect/vue-treeselect.css" rel="stylesheet" />
    <script src="../static/js/vue-treeselect/vue-treeselect.js"></script>
    <style>
        body {
            padding-bottom: 10px;
        }

        .vue-treeselect_style .vue-treeselect__control {
            height: 100%;
            border: none;
            background: none;
        }

        .vue-treeselect__placeholder {
            top: -3px;
        }

        .vue-treeselect__single-value {
            top: -3px;
        }

        .vue-treeselect__input {
            height: 27px !important;
        }
    </style>
    <style>
        .el-table {
            overflow: visible !important;
        }
        .el-table__row .cell {
            overflow: visible !important;
        }
        
        .el-table .cell, .el-table th div {
            overflow: visible !important;
        }
        
        .el-table__body-wrapper {
            overflow: visible !important;
        }
            .vue-treeselect__menu-container {
                position: absolute; /*position: absolute; */
                z-index: 99999 !important;
            }

        .vue-treeselect__menu {
            position: absolute;
            z-index: 99999 !important;
        }
        /*.elst-select-mini .el-form-item__content {
            text-align: left;
        }*/
    </style>
    <style>
        h3 {
            text-align: center;
        }

            h3 .elst-select-mini {
                width: 200px;
                display: inline-block;
            }

                h3 .elst-select-mini .el-input__inner {
                    font-size: 17px
                }

        .remark {
            color: #606266;
            margin-left: 40px;
            font-size: 14px;
        }

        .el-form-item__content {
            margin-left: 0px !important;
        }

        .el-form-item {
            margin-bottom: 0px !important;
        }

        .td-p {
            float: left;
            margin: 4px;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak class="popupW100">
        <el-form :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="180px" size="mini"
                 label-position="right">
            <el-row>
                <h3>
                    承包商总体评价结果
                </h3>
            </el-row> <el-row style="padding-bottom:10px;">
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini">
                                <template slot="prepend">
                                    <div> {{"评估类别"+mark.m}}</div>
                                </template>
                                <el-select @visible-change="visibleChange" v-model="Form.assessTypeId" slot="suffix" @change="postChange">
                                    <el-option label="请选择" value=""></el-option>
                                    <el-option v-for="item in Type" :label="item.value" :value="item.id">
                                    </el-option>
                                </el-select>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="11" :offset="2">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini">
                                <template slot="prepend">
                                    <div> {{OverallAssessment.ContractorName+mark.m}}</div>
                                </template>
                                <el-select @visible-change="visibleChange" v-model="Form.cbsListID" slot="suffix"
                                           :placeholder="DailyAssessment.ContractorName"  @change="postChange2">
                                    <el-option label="请选择" value=""></el-option>
                                    <el-option v-for="item in CBS_Lists" :label="item.contractorName"
                                               :value="item.id"></el-option>
                                </el-select>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row> 
            <el-row style="padding-bottom:10px;">
                <el-table :data="Form.cbS_TotalCheckDetail" stripe border="" show-summary style="width: 100%">
                    <el-table-column type="index" :label="col.SequenceNumber" :index="indexMethod" width="85"
                                     show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="cbS_TotalCheckItem.checkProject" :label="DailyAssessment.ExamContent">
                    </el-table-column>
                    <el-table-column prop="cbS_TotalCheckItem.weightPoints" sortable :label="OverallAssessment.Weight">
                        <!-- <template slot-scope="scope">
            <el-input type="text" v-model="scope.row.Weight" autocomplete="off" size="mini">
            </el-input>
        </template> -->
                    </el-table-column>
                    <el-table-column prop="score" sortable :label="OverallAssessment.Score">
                        <template slot-scope="scope">
                            <!--<span v-if="scope.row.ExamContent == '承包商总体工作表现评估'">
        {{scope.row.score}}
    </span>
    <el-input v-else type="text" v-model="scope.row.score" autocomplete="off" size="mini">
    </el-input>-->
                            <el-input v-if="scope.row.cbS_TotalCheckItem.checkProject.indexOf('日常')>=0" disabled type="text" v-model="scope.row.score" autocomplete="off" size="mini">
                            </el-input>
                            <el-input v-else type="text" v-model="scope.row.score" autocomplete="off" size="mini">
                            </el-input>
                        </template>
                    </el-table-column>
                    <el-table-column prop="reviewPeople" :label="OverallAssessment.Evaluator">
                        <template slot-scope="scope">

                                <tree-department-staff-single slot="suffix" v-model="scope.row.reviewPeople" style="line-height:28px;"></tree-department-staff-single>
                            
                        </template>
                    </el-table-column>
                    <el-table-column prop="id" width="1" :show-overflow-tooltip="true">
                        <template slot-scope="scope">
                            <span style="display:none;">{{scope.row.id}}</span>
                        </template>
                    </el-table-column>
                </el-table>
                <div class="el-table el-table--fit el-table--striped el-table--border el-table--enable-row-hover el-table--enable-row-transition"
                     style="width: 100%;">
                    <div class="">
                        <table cellspacing="0" cellpadding="0" border="0" class="el-table__footer" style="width: 100%">
                            <tbody class="has-gutter">
                                <tr>
                                    <td colspan="1" rowspan="1" class="el-table_1_column_1 is-leaf" style="width: 85px">
                                        <div class="cell">{{OverallAssessment.summary+mark.m}}</div>
                                    </td>
                                    <td colspan="1" rowspan="1" class="el-table_1_column_2 is-leaf">
                                        <el-row class="cell">
                                            <p class="td-p">属地主管：</p>
                                            <div class="elst-select-mini">
                                                <el-form-item>
                                                    <div style="position: absolute;z-index:999;left:0;right:0;margin-left:100px;">
                                                        <tree-department-staff-single slot="suffix" v-model="Form.territorialAppraiser" style="line-height:28px;width:300px;"></tree-department-staff-single>
                                                    </div>
                                                </el-form-item>
                                            </div>
                                            <!--<br>
                <el-row>
                    <el-col :span="12">
                        <p class="td-p">{{col.btnSign}}：</p>
                        <signature class="fl" v-model="value" :disabled="false"></signature>
                    </el-col>
                    <el-col :span="12">
                        <div class="elst-select-mini fr">
                            <el-form-item>
                                <el-date-picker v-model="Form.territorialEvaluationDate" type="date"
                                                placeholder="选择日期">
                                </el-date-picker>
                            </el-form-item>
                        </div>
                        <p class="td-p fr">{{OverallAssessment.Data+mark.m}}</p>
                    </el-col>
                </el-row>-->
                                        </el-row>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="1" rowspan="1" class="el-table_1_column_1 is-leaf" style="width: 85px">
                                        <div class="cell">{{OverallAssessment.summary+mark.m}}</div>
                                    </td>
                                    <td colspan="1" rowspan="1" class="el-table_1_column_2 is-leaf">
                                        <el-row class="cell">
                                            <p class="td-p">业务管理部门：</p>
                                            <div class="elst-select-mini">
                                                <el-form-item>
                                                    <div style="position: absolute;margin-left:100px;">
                                                        <el-input type="text" v-model="Form.businessManagementName" autocomplete="off" style="width:160px !important;" size="mini">
                                                        </el-input>
                                                    </div>
                                                    <!--<el-select @visible-change="visibleChange" v-model="Form.businessManagementEvaluator">
                            <el-option label="请选择" value=""></el-option>
                            <el-option v-for="item in Qualified" :label="item.value"
                                       :value="item.value">
                            </el-option>
                        </el-select>-->

                                                </el-form-item>
                                            </div>
                                            <!--<br>
                <el-row>
                    <el-col :span="12">
                        <p class="td-p">{{col.btnSign}}：</p>
                        <signature class="fl" v-model="value" :disabled="false"></signature>
                    </el-col>
                    <el-col :span="12">
                        <div class="elst-select-mini fr">
                            <el-form-item>
                                <el-date-picker v-model="Form.businessManagementEvaluationData" type="date"
                                                placeholder="选择日期">
                                </el-date-picker>
                            </el-form-item>
                        </div>
                        <p class="td-p fr">{{OverallAssessment.Data+mark.m}}</p>
                    </el-col>
                </el-row>-->
                                        </el-row>
                                    </td>
                                </tr>
                             
                                    <tr v-for='item in Form.cbS_TotalCheckHeadApprove'>
                                        <td colspan="1" rowspan="1" class="el-table_1_column_1 is-leaf" style="width: 85px">
                                            <div class="cell">{{OverallAssessment.results+mark.m}}</div>
                                        </td>
                                        <td colspan="1" rowspan="1" class="el-table_1_column_2 is-leaf">
                                            <el-row class="cell">
                                              
                                                <div class="elst-select-mini">
                                                    <el-form-item>
                                                        <div style="position: absolute;margin-top:-15px;">
                                                            <el-input type="text" v-model="item.sysDuty.name" autocomplete="off" style="width:160px !important;" size="mini">
                                                            </el-input>
                                                            </div>
                                                        </el-form-item>
                                                    </div>
                                                </el-row>
                                        </td>
                                    </tr>
                              
                                <!--<tr>
                            <td colspan="1" rowspan="1" class="el-table_1_column_1 is-leaf" style="width: 85px">
                                <div class="cell">{{OverallAssessment.results+mark.m}}</div>
                            </td>
                            <td colspan="1" rowspan="1" class="el-table_1_column_2 is-leaf">
                                <el-row class="cell">
                                    <p class="td-p">是否列入合格承包商名录：</p>
                                    <div class="elst-select-mini">
                                        <el-form-item>
                                            <el-select @visible-change="visibleChange" v-model="Form.isContractorDirectory">
                                                <el-option label="请选择" value=""></el-option>
                                                <el-option v-for="item in YesOrNo" :label="item.value"
                                                           :value="item.value">
                                                </el-option>
                                            </el-select>
                                        </el-form-item>
                                    </div>
                                  <br>
        <el-row>
            <el-col :span="12">
                <p class="td-p">{{col.btnSign}}：</p>
                <signature class="fl" v-model="value" :disabled="false"></signature>
            </el-col>
            <el-col :span="12">
                <div class="elst-select-mini fr">
                    <el-form-item>
                        <el-date-picker v-model="Form.summaryEvaluationDate" type="date"
                                        placeholder="选择日期">
                        </el-date-picker>
                    </el-form-item>
                </div>
                <p class="td-p fr">{{OverallAssessment.Data+mark.m}}</p>
            </el-col>
        </el-row>
    </el-row>
                                        </td>
                                    </tr>-->
                            </tbody>
                        </table>
                    </div>
                    
                </div>
            </el-row>
        </el-form>
        <br>
        <p class="remark">
            <strong>说明：</strong><br>
            1.此表作为财务结算的必须凭据；
            <br>
            2.此表作为下一次合同招(议)标的重要推荐依据。
        </p>
        <br>
        <div class="fr" style="margin-bottom:10px;">
            <el-button type="primary" @click="onSubmitForm('ruleForm','0')">{{col.btnSave}}</el-button>
            <el-button type="primary" @click="onSubmitForm('ruleForm','1')">{{col.btnCommit}}</el-button>
            <el-button type="primary" @click="parent.ListItem.dialogVisible=false">{{col.btnBack}}</el-button>
        </div>
    </div>

    <script type="text/javascript">

        var app = new Vue({
            el: '#app',
            data: {
                id: '',
                value: "",
                //tableData6: [
                //    {
                //        id: '12987122',
                //        ExamContent: '承包商总体工作表现评估',
                //        Weight: '30',
                //        Score: '8',
                //        Evaluator: '汪军',
                //    }, {
                //        id: '12987123',
                //        ExamContent: '承包商定期工作评估',
                //        Weight: '20',
                //        Score: '9',
                //        Evaluator: '曹伟',
                //    }, {
                //        id: '12987124',
                //        ExamContent: '项目的 HSE 费用、清单及承诺落实情况',
                //        Weight: '20',
                //        Score: '7',
                //        Evaluator: '苏秀兰',
                //    }, {
                //        id: '12987125',
                //        ExamContent: '工作态度和配合度',
                //        Weight: '10',
                //        Score: '3',
                //        Evaluator: '秦艳',
                //    },
                //    {
                //        id: '12987126',
                //        ExamContent: '伤害及事故',
                //        Weight: '20',
                //        Score: '5',
                //        Evaluator: '白敏',
                //    }
                //],
                tableData: [],
                //业务表单内容
                Form: {
                    id: guidEmpty,
                    Type: '',
                    Qualified: '',
                    YesOrNo: '',
                    Data: '',
                    isContractorDirectory:0,
                    OverallAssessmentTypeName: '',//总体评估考核类别名称
                    assessTypeId: '',
                    contractorName: '', //"承包商名称"
                    contractNo: '',//合同号
                    projectName: '', //"项目名称"
                    mark01: '',//满分
                    mark02:'0',//领导审批顺序
                    state: '',//状态
                    CommentItem: '',
                    TheWeight: '',
                    fraction: '',//得分
                    EvaluationDescription: '',
                    cbS_TotalCheckDetail: [],
                    businessManagementEvaluator: '',//业务管理部门ID
                    businessManagementName: '',
                    cbS_TotalCheckHeadApprove: []//总体评估考核领导签字

                },
                Type: [],
                TotalCheckTaskID: '',
                CBS_Lists: [],
                Qualified: [],
                YesOrNo: [],
                Data: [],
                ContractorName: [],
                ListItem: ListItem,
                OverallAssessmentTypeName: [],
                CategoryManage: [],
                delIds: [],
                delIds2: [],
                //表单验证
                rules: {

                }
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                handleChange: function (value) {
                    console.log(value);
                },
                ////提交数据
                //onSubmitForm: function (formName) {
                //    var mythis = this;
                //    this.$refs[formName].validate(function (valid) {
                //        //验证通过
                //        if (valid) {
                //            console.log(111)
                //            console.log(mythis.Form)
                //            onSubmitForm(this, '/api/Overall/Save', mythis.Form);
                //        } else {
                //            //验证失败
                //            return false;
                //        }
                //    });
                //},
                //提交数据
                onSubmitForm: function (formName,state) {
                    var mythis = this;
                    this.$refs[formName].validate(function (valid) {
                        //验证通过
                        if (valid) {
                            if (mythis.Form.assessTypeId == null || mythis.Form.assessTypeId == "" || mythis.Form.assessTypeId == undefined) {
                                alert('请选择承包商类型');
                                return;
                            }

                            if (mythis.Form.cbsListID == null || mythis.Form.cbsListID == "" || mythis.Form.cbsListID == undefined) {
                                alert('请选择承包商');
                                return;
                            }

                            //if (mythis.Form.assessUserId == null || mythis.Form.assessUserId == "" || mythis.Form.assessUserId == undefined) {
                            //    alert('请选择评估人');
                            //    return;
                            //}
                            //if (mythis.Form.assessDate == null || mythis.Form.assessDate == "" || mythis.Form.assessDate == undefined) {
                            //    alert('请选择评估日期');
                            //    return;
                            //}

                            if (mythis.Form.cbS_TotalCheckDetail == null || mythis.Form.cbS_TotalCheckDetail.length == 0) {
                                alert('没有考核内容');
                                return;
                            }
                            if (mythis.Form.territorialAppraiser == null || mythis.Form.territorialAppraiser == "" || mythis.Form.territorialAppraiser == undefined) {
                                alert('请选择属地主管');
                                return;
                            }
                         
                            mythis.Form.state = state;
                            //onSubmitForm(this, '/api/CBS_TotalCheck/Save', mythis.Form);
                            mythis.Form.totalCheckTaskID = mythis.totalCheckTaskID;
                            for (var z = 0; z < mythis.CBS_Lists.length; z++) {
                                if (mythis.Form.cbsListID == mythis.CBS_Lists[z].id) {
                                    mythis.Form.contractorName = mythis.CBS_Lists[z].contractorName;
                                    break;
                                }
                            }
                            var list = mythis.Form.cbS_TotalCheckDetail;
                            var list2 = mythis.Form.cbS_TotalCheckHeadApprove;
                            //循环考核明细
                            var isScore = "0";
                            var tempsum = 0;
                            var tempsumscore = 0;
                            for (var i = 0; i < list.length; i++) {
                                tempsum = parseInt(tempsum) + parseInt(list[i].score);
                                tempsumscore = parseInt(tempsumscore) + parseInt(list[i].cbS_TotalCheckItem.weightPoints);
                                if (parseInt(list[i].score) < 0 || parseInt(list[i].score) > parseInt(list[i].fullScore)) {
                                    alert(list[i].cbS_TotalCheckItem.checkProject + "得分不能大于" + list[i].fullScore);
                                    isScore = "1";
                                    return;
                                }
                                //判断评估人
                                if (list[i].reviewPeople == null || list[i].reviewPeople == "" || list[i].reviewPeople == undefined) {
                                    alert(list[i].cbS_TotalCheckItem.checkProject + "请选择评估人");
                                    isScore = "2";
                                    return;
                                }

                            }
                            if (parseInt(tempsum) > 100) {
                                alert('总分不能大于100');
                                return;
                            }
                            mythis.Form.mark01 = tempsumscore;
                            mythis.Form.fraction = tempsum;
                            if (isScore == "0") {
                                var isExist = "0";
                                if (mythis.id == null || mythis.id == "" || mythis.id == undefined || mythis.id == "undefined") {
                                    //当前考核是否存在
                                    myAjax("post", this, '/api/CBS_TotalCheck/GetList', { model: { totalCheckTaskID: mythis.Form.totalCheckTaskID, assessTypeId: mythis.Form.assessTypeId, cbsListID: mythis.Form.cbsListID }, offset: 0, limit: 10 }, function (response) {
                                        if (response.data.pageData.length == 0) {
                                            myAjax("post", mythis, '/api/CBS_TotalCheck/Save', mythis.Form, function (response1) {
                                                var cbSTotalCheckId = response1.data; //总体评估考核ID
                                                if (mythis.id == null || mythis.id == "" || mythis.id == undefined || mythis.id == "undefined") {

                                                } else {
                                                    cbSTotalCheckId = mythis.id;
                                                }


                                                //循环考核明细
                                                for (var j = 0; j < list.length; j++) {
                                                    list[j].cbSTotalCheckId = cbSTotalCheckId;
                                                    myAjax("post", mythis, '/api/CBS_TotalCheckDetail/Save', list[j], function (response4) {
                                                    });
                                                }
                                                //添加考核领导
                                                for (var z = 0; z < list2.length; z++) {
                                                    list2[z].totalCheckID = cbSTotalCheckId;
                                                    list2[z].mark01 = list2[z].approveOrder;
                                                    myAjax("post", mythis, '/api/CBS_TotalCheckHeadApprove/Save', list2[z], function (response4) {
                                                    });
                                                }

                                                showMessage(msg.OperatingOk, 'success');
                                                parent.app.ListItem.dialogVisible = false;

                                            });
                                        } else {
                                            alert('考核已存在');
                                            return;
                                        }
                                    });
                                    

                                } else {
                                    myAjax("post", mythis, '/api/CBS_TotalCheck/Save', mythis.Form, function (response1) {
                                        var cbSTotalCheckId = response1.data; //总体评估考核ID
                                        if (mythis.id == null || mythis.id == "" || mythis.id == undefined || mythis.id == "undefined") {

                                        } else {
                                            cbSTotalCheckId = mythis.id;
                                        }


                                        //循环考核明细
                                        for (var j = 0; j < list.length; j++) {
                                            list[j].cbSTotalCheckId = cbSTotalCheckId;
                                            myAjax("post", mythis, '/api/CBS_TotalCheckDetail/Save', list[j], function (response4) {
                                            });
                                        }

                                        //考核领导
                                        for (var z = 0; z < list2.length; z++) {
                                            list2[z].totalCheckID = cbSTotalCheckId;
                                            list2[z].mark01 = list2[z].approveOrder;
                                            myAjax("post", mythis, '/api/CBS_TotalCheckHeadApprove/Save', list2[z], function (response4) {
                                            });
                                        }
                                        //删除子集
                                        if (mythis.delIds.length > 0) {
                                            myAjax("post", this, '/api/CBS_TotalCheckDetail/DeleteMuti', mythis.delIds, function (response) {
                                                mythis.delIds = [];
                                            });
                                        }
                                        //删除子集
                                        if (mythis.delIds2.length > 0) {
                                            myAjax("post", this, '/api/CBS_TotalCheckHeadApprove/DeleteMuti', mythis.delIds2, function (response) {
                                                mythis.delIds2 = [];
                                            });
                                        }

                                        showMessage(msg.OperatingOk, 'success');
                                        parent.app.ListItem.dialogVisible = false;

                                    });
                                } 
                                
                            }
                        } else {
                            //验证失败
                            return false;
                        }
                    });
                },
                getData: function () {
                    var mythis = this;
                    if (mythis.id == null || mythis.id == "" || mythis.id == undefined || mythis.id == "undefined") {
                        mythis.Form.cbS_TotalCheckDetail = [];
                    } else {
                        getData(mythis, '/api/CBS_TotalCheck/get?id=' + mythis.id);
                        myAjax("post", mythis, '/api/CBS_TotalCheckDetail/GetList', { model: { cbSTotalCheckId: mythis.id }, offset: 0, limit: 100 }, function (response) {
                            mythis.Form.cbS_TotalCheckDetail = response.data.pageData;
                            //console.log('h1', response.data.pageData);
                        }, false);
                        myAjax("post", mythis, '/api/CBS_TotalCheckHeadApprove/GetList', { model: { totalCheckID: mythis.id }, offset: 0, limit: 100 }, function (response) {
                            mythis.Form.cbS_TotalCheckHeadApprove = response.data.pageData;
                            //console.log('h1', response.data.pageData);
                        }, false);
                        //承包商类别审批领导
                        //this.getCategoryApproveDuty();
                        //this.changeAssessType(mythis.Form.assessTypeId);
                        //承包商类别同主管部门
                        for (var i = 0; i < this.CategoryManage.length; i++) {
                            if (this.Form.businessManagementEvaluator == this.CategoryManage[i].manageDept) {
                                //this.Form.businessManagementEvaluator = this.CategoryManage[i].manageDept;
                                this.Form.businessManagementName = this.CategoryManage[i].sysDepartment.name;
                            }
                        }
                    }
                },
                onBack: function () {
                    parent.app.ListItem.dialogVisible = false;
                },
                indexMethod: function (index) {
                    return (this.ListItem.currentPage - 1) * this.ListItem.pagesize + index + 1;
                },
                //初始化承包商类型
                getTypeList: function () {
                    var mythis = this;
                    myAjax("post", this, '/api/CBS_DayCheckItem/CBSsglbGetList', { model: { category: 'cbssglb' }, offset: 0, limit: 100 }, function (response) {
                        mythis.Type = response.data;

                        //console.log(response.data.pageData);
                    }, false);
                },
                //初始化承包商下拉框
                getCBS_List: function () {
                    var mythis = this;
                    if (mythis.Form.assessTypeId == null || mythis.Form.assessTypeId == "" || mythis.Form.assessTypeId == undefined) {
                        myAjax("post", this, '/api/CBS_List/GetList', { model: { status: '', CreateFactory: null }, offset: 0, limit: 100 }, function (response) {
                            mythis.CBS_Lists = response.data.pageData;
                            //console.log('h1', response.data.pageData);
                        }, false);
                    } else {
                        var cc = "";
                        for (var i = 0; i < mythis.Type.length; i++) {
                            if (mythis.Type[i].id == mythis.Form.assessTypeId) {
                                cc = mythis.Type[i].key;
                            }
                        }
                        //供应商表施工类别与PD的不一致实际不是id是key
                        myAjax("post", this, '/api/CBS_List/GetList', { model: { constructionCategory: cc, CreateFactory: null }, offset: 0, limit: 100 }, function (response) {
                            mythis.CBS_Lists = response.data.pageData;
                            //console.log('h1', response.data.pageData);
                        }, false);
                    }
                },
                getCategoryManage: function () {
                    var mythis = this;
                    if (mythis.Form.assessTypeId == null || mythis.Form.assessTypeId == "" || mythis.Form.assessTypeId == undefined) {
                        myAjax("post", this, '/api/CBS_CategoryManage/GetList', { model: { status: '', CreateFactory: null }, offset: 0, limit: 100 }, function (response) {
                            mythis.CategoryManage = response.data.pageData;
                            //console.log('h1', response.data.pageData);
                        }, false);
                    } else {
                        myAjax("post", this, '/api/CBS_CategoryManage/GetList', { model: { constructionCategory: mythis.Form.assessTypeId, CreateFactory: null }, offset: 0, limit: 100 }, function (response) {
                            mythis.CategoryManage = response.data.pageData;
                            //console.log('h1', response.data.pageData);
                        }, false);
                    }
                }, 
                getCategoryApproveDuty: function() {
                    var mythis = this;
                    if (mythis.Form.assessTypeId == null || mythis.Form.assessTypeId == "" || mythis.Form.assessTypeId == undefined) {
                        mythis.Form.cbS_TotalCheckHeadApprove = [];
                    } else {
                        var templist = mythis.Form.cbS_TotalCheckHeadApprove;
                        if (templist == undefined || templist == null || templist.length == 0) { } else {
                            for (var z = 0; z < templist.length; z++) {
                                if (templist[z].id == undefined || templist[z].id == null || templist[z].id == "") { } else {
                                    mythis.delIds2.push(templist[z].id);
                                }
                            }
                        }
                        myAjax("post", this, '/api/CBS_CategoryApproveDuty/GetList', { model: { constructionCategory: mythis.Form.assessTypeId, CreateFactory: null }, offset: 0, limit: 100 }, function (response) {
                            //mythis.Form.cbS_TotalCheckHeadApprove = response.data.pageData;
                            var list = response.data.pageData;
                            mythis.Form.cbS_TotalCheckHeadApprove = [];
                            for (var i = 0; i < list.length; i++) {
                                mythis.Form.cbS_TotalCheckHeadApprove.push({ sysDuty: list[i].sysDuty, approveOrder: list[i].approveOrder, dutyId: list[i].dutyId, constructionCategory: list[i].constructionCategory });
                            }
                            //console.log('h1', response.data.pageData);
                        }, false);
                    }
                },
                changeAssessType: function (assessTypeId) {
                    var mythis = this;
                    if (assessTypeId == null || assessTypeId == "" || assessTypeId == undefined) { } else {
                        var templist = mythis.Form.cbS_TotalCheckDetail;

                        for (var z = 0; z < templist.length; z++) {
                            if (templist[z].id == undefined || templist[z].id == null || templist[z].id == "") { } else {
                                mythis.delIds.push(templist[z].id);
                            }
                        }

                        myAjax("post", mythis, '/api/CBS_TotalCheckItem/GetList', {
                            model: { assessTypeId: assessTypeId }, offset: 0, limit: 100
                        }, function (response) {
                            //console.log(response);
                            if (response.data.pageData.length == 0) {
                                mythis.Form.cbS_TotalCheckDetail = [];
                                mythis.tableData = [];
                            } else {
                                mythis.tableData = response.data.pageData;
                                mythis.Form.cbS_TotalCheckDetail = [];
                                for (var i = 0; i < mythis.tableData.length; i++) {
                                    //日常平均分判断获取
                                    if (mythis.tableData[i].checkProject.toString().indexOf('日常') >= 0 && i < mythis.tableData.length-1) {
                                        if (mythis.Form.cbsListID == null || mythis.Form.cbsListID == "" || mythis.Form.cbsListID == undefined) {
                                            mythis.Form.cbS_TotalCheckDetail.push({ cbS_TotalCheckItem: { checkProject: mythis.tableData[i].checkProject, weightPoints: mythis.tableData[i].weightPoints }, cbSTotalCheckItemId: mythis.tableData[i].id, fullScore: mythis.tableData[i].weightPoints, score: 0 });
                                        } else {
                                            var tempi = i;
                                            var qzf = parseInt(mythis.tableData[i].weightPoints);
                                            var cp = mythis.tableData[i].checkProject;
                                            var tid = mythis.tableData[i].id;
                                            //获取平均分  this.totalCheckTaskID//任务  承包商
                                            myAjax("post", mythis, '/api/CBS_TotalCheck/GetAvg', {
                                                model: { cbsListID: mythis.Form.cbsListID, totalCheckTaskID: mythis.totalCheckTaskID }, offset: 0, limit: 100
                                            }, function (responseA) {
                                                //console.log(response);
                                                if (responseA.data.length == 0) {
                                                    mythis.Form.cbS_TotalCheckDetail.unshift({ cbS_TotalCheckItem: { checkProject: mythis.tableData[tempi].checkProject, weightPoints: mythis.tableData[tempi].weightPoints }, cbSTotalCheckItemId: mythis.tableData[tempi].id, fullScore: mythis.tableData[tempi].weightPoints, score: 0 });

                                                } else {
                                                    var tempAvg = 0;
                                                    tempAvg = parseInt(qzf* parseInt(responseA.data) * 0.01);

                                                    mythis.Form.cbS_TotalCheckDetail.unshift({ cbS_TotalCheckItem: { checkProject: cp, weightPoints: qzf }, cbSTotalCheckItemId: tid, fullScore: qzf, score: tempAvg });
                                                }
                                            });
                                        }
                                    } else {
                                        mythis.Form.cbS_TotalCheckDetail.push({ cbS_TotalCheckItem: { checkProject: mythis.tableData[i].checkProject, weightPoints: mythis.tableData[i].weightPoints }, cbSTotalCheckItemId: mythis.tableData[i].id, fullScore: mythis.tableData[i].weightPoints, score: 0 });
                                    }
                                    
                                }

                            }
                        });
                    }
                },
                postChange: function (val) {
                    //根据类型 筛选承包商
                    this.getCBS_List();
                    //承包商类别审批领导
                    this.getCategoryApproveDuty();
                    this.changeAssessType(val);
                    //承包商类别同主管部门
                    for (var i = 0; i < this.CategoryManage.length; i++) {
                        if (val == this.CategoryManage[i].constructionCategory) {
                            this.Form.businessManagementEvaluator = this.CategoryManage[i].manageDept;
                            this.Form.businessManagementName = this.CategoryManage[i].sysDepartment.name;
                        }
                    }

                },
                postChange2: function (val) {
                    var mythis = this;
                    for (var i = 0; i < mythis.Form.cbS_TotalCheckDetail.length; i++) {
                        //日常平均分判断获取
                        if (mythis.Form.cbS_TotalCheckDetail[i].cbS_TotalCheckItem.checkProject.toString().indexOf('日常') >= 0) {
                            if (val == null || val == "" || val == undefined) {

                            } else {
                                var tempi = i;
                                //获取平均分  this.totalCheckTaskID//任务  承包商
                                myAjax("post", mythis, '/api/CBS_TotalCheck/GetAvg', {
                                    model: { cbSListID: val, totalCheckTaskID: mythis.totalCheckTaskID }, offset: 0, limit: 100
                                }, function (responseA) {
                                    //console.log(response);
                                    if (responseA.data.length == 0) {
                                        
                                    } else {
                                        var tempAvg = 0;
                                        tempAvg = parseInt(parseInt(mythis.Form.cbS_TotalCheckDetail[tempi].cbS_TotalCheckItem.weightPoints) * parseInt(responseA.data) * 0.01);
                                        mythis.Form.cbS_TotalCheckDetail[tempi].score = tempAvg;
                                    }
                                });
                            }
                        } else {
                            }

                    }

                }
            },
            mounted: function () {
                //this.Type = getDicData('29');
                //this.Qualified = getDicData('57');
                //this.YesOrNo = getDicData('50');
                //this.ContractorName = getDicData('139');
                //this.OverallAssessmentTypeName = getDicData('56');
                //this.id = getUrlParam("id");
                this.id = getUrlParam("id");
                this.totalCheckTaskID = getUrlParam("totalCheckTaskID");
                this.getTypeList();//评估类别
                this.getCBS_List();//承包商
                this.getCategoryManage();//承包商类别同主管部门
                this.getCategoryApproveDuty();//承包商类别审批领导
                this.getData();
            }
        });
    </script>
</body>

</html>